function violence(weights, values, capacity, n) {
  // 背包剩余容量为0 || 剩下的物品数量为0
  if (capacity === 0 || n === 0) return 0

  // 当前的物品索引是 n - 1,可以拿或者不拿

  if (weights[n - 1] > capacity) {
    return violence(weights, values, capacity, n - 1)
  } else {
    // 不拿 || 拿
    return Math.max(
      violence(weights, values, capacity, n - 1),
      violence(weights, values, capacity - weights[n - 1], n - 1)
    )
  }
}

const weights = [1, 2, 3, 4, 5]
const values = [10, 20, 30, 40, 50]
const capacity = 7
const n = weights.length
